resource "google_dialogflow_cx_agent" "agent" {
  display_name = "<%= ctx[:vars]["agent_name"] %>"
  location = "global"
  default_language_code = "en"
  supported_language_codes = ["fr","de","es"]
  time_zone = "America/New_York"
  description = "Example description."
  avatar_uri = "https://cloud.google.com/_static/images/cloud/icons/favicons/onecloud/super_cloud.png"
  enable_stackdriver_logging = true
  enable_spell_correction    = true
	speech_to_text_settings {
		enable_speech_adaptation = true
	}
}


resource "google_dialogflow_cx_page" "<%= ctx[:primary_resource_id] %>" {
  parent       = google_dialogflow_cx_agent.agent.start_flow
  display_name = "MyPage"

  entry_fulfillment {
		messages {
			text {
				text = ["Welcome to page"]
			}
		}
   }

   form {
		parameters {
			display_name = "param1"
			entity_type  = "projects/-/locations/-/agents/-/entityTypes/sys.date"
			fill_behavior {
				initial_prompt_fulfillment {
					messages {
						text {
							text = ["Please provide param1"]
						}
					}
				}
			}
			required = "true"
			redact   = "true"
		}
	}

    transition_routes {
		condition = "$page.params.status = 'FINAL'"
		trigger_fulfillment {
			messages {
				text {
					text = ["information completed, navigating to page 2"]
				}
			}
		}
		target_page = google_dialogflow_cx_page.my_page2.id
	}
} 

resource "google_dialogflow_cx_page" "my_page2" {
    parent       = google_dialogflow_cx_agent.agent.start_flow
    display_name  = "MyPage2"
}